import cv2
import numpy as np


# https://zhuanlan.zhihu.com/p/672739814
def test():
    #
    img = cv2.imread('card.png')

    # 定义仿射变换矩阵
    # 例如，这里定义一个向右平移 50 像素，向下平移 100 像素的变换
    M = np.float32([[1, 0, 50], [0, 1, 100]])

    # 应用仿射变换
    transformed_img = cv2.warpAffine(img, M, (img.shape[1], img.shape[0]))
    # 显示结果
    cv2.imshow('Transformed Image', transformed_img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


if __name__ == '__main__':
    test()
